<template>
    <div class="background" id = "login-all">
        <!-- <div class="leftbox"> -->
        <div class = "leftbox">
            <div class="left-content">
                <h1>暑假培训项目</h1>
                <p>高效便捷的登录平台</p>
            </div>
        </div>
        <div class="rightbox">
            <div class="rightbox-outer">
                <div class="rightbox-header">登录</div>
                <div class="errormassage">{{ errormassage }}</div>
                <div class="input-group">
                    <input type="text" class="userinput" placeholder="请输入用户名、邮箱、手机号" v-model = "username">
                </div>
                <div class="input-group">
                    <input type="password" class="passwordinput" placeholder="请输入密码" v-model = "password">
                </div>
                <button class="loginbutton" @click = "handleLogin" >登录</button>
                <div class="partting ">
                    <div @click = "register" class = "register">还没有账号？立即注册</div>
                    <div @click = "reset" class = "register1">忘记密码？</div>
                </div>
            </div>
        </div>
    </div>
</template>

<script setup>
import { useRouter } from 'vue-router'
import { ref } from 'vue'

const router = useRouter()
const username = ref('')
const password = ref('')
const errormassage = ref('')

const handleLogin = () => {
    if (username.value === ''){
        errormassage.value = '用户名不能为空!'
        return
    }
    if (password.value === ''){
        errormassage.value = '密码不能为空！'
        return
    }
    router.push('/App')
}
const register = () => {
    router.push('/Register')
}
const reset = () => {
    router.push('/Reset')
}
</script>
<style scoped>

.background {
    display: flex;
    flex-direction: row;
    min-height: 100vh;
    margin: 0;
}

#login-all {
  position: absolute;
  height: 100%;
  width: 100%;
  top: 0;
  left: 0;
  background-image: linear-gradient(90deg, cyan, purple); 
  background-size: 400%;
  animation: myanimation 10s infinite; 
}

@keyframes myanimation {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

.leftbox {
    width: 52%;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.left-content {
    text-align: center;
    color: white;
    padding: 20px;
    z-index: 1;
}

.left-content h1 {
    font-size: 48px;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.left-content p {
    font-size: 20px;
    line-height: 1.6;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.2);
}

.rightbox {
    position: absolute;
    top: 0;
    right: 0;
    background-color: #fff;
    width: 45%;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}


.rightbox-outer {
    background-color: #fff;
    width: 400px;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.rightbox-header {
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 40px;
}


.input-group {
    width: 100%;
    margin-bottom: 20px;
}

.userinput,
.passwordinput {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 16px;
    box-sizing: border-box;
}

.userinput:focus,
.passwordinput:focus {
    outline: none;
    border-color: #3093db;
    box-shadow: 0 0 5px rgba(48, 147, 219, 0.5);
}

.loginbutton {
    width: 100%;
    padding: 12px;
    background-color: #3093db;
    color: #fff;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.loginbutton:hover {
    background-color: #207abd;
}

.partting {
    display:flex;
    width: 100%;
    margin-top: 20px;
}

.register{
    font-size: 14px;
    width: 50%;
    cursor: pointer;
    color: #3093db;
    text-decoration: none;
}

.register1 {
    text-decoration: underline;
    font-size: 14px;
    padding-left: 30%;
    cursor: pointer;
    color: #3093db;
    text-decoration: none;
}

.register:hover {
    text-decoration: underline;
}

.register1:hover{
    text-decoration: underline;
}

.errormassage {
    color: red;
    font-size: 16px;
    margin-bottom: 20px;
}
</style>